<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="加密方式" prop="title">
        <el-radio-group v-model="form.strategy">
          <el-radio label="symmetry">对称加密</el-radio>
          <el-radio label="asymmetric">非对称加密</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">保 存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

import { settingSaveUpdate, settingList } from "@/api/system/safety";
export default {
  name: "Pic",
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      loading: false, // 遮罩层
      form: {
        strategy: 'symmetry' // 微信公众号二维码
      },
      rules: {},
    };
  },
  created() {
    this.getInfo();
  },
  methods: {
    /** 查询网站信息 */
    getInfo() {
      this.loading = true;
      settingList({ key: "USER_LOGIN_STRATEGY" })
        .then((res) => {
          this.form = JSON.parse(res.data.settingValue);
        })
        .finally(() => {
          this.loading = false;
        });
    },
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.loading = true;
          settingSaveUpdate({
            id: "USER_LOGIN_STRATEGY",
            settingValue: JSON.stringify(this.form),
          }).then((res) => {
            this.$message.success(res.msg);
            this.getInfo()
          });
        }
      });
    },
  },
};
</script>
